import Mock from "mockjs"
export default {
    'GET /api/user': {
        username: '解加怡',
        sex: 0,
        role:2  
        //  0/1/2/3/4   0代表 普通，1是会员 2是超级会员 3是管理员
    },

    "GET /api/getOrderList": function (req,res) {
        const {type} = req.body;
        return res.json(Mock.mock({
            code: 200,
            msg: "操作成功",
            data: {
                current_page: 1,
                last_page: 10,
                total: 178,
                "list|10": [
                    {
                        id: "@id", //模拟id
                        "price|10000-2000": 5000, //模拟小数，在计算机中也称浮点数
                        "isHotOrder|1-2": true, //模拟状态值,0,1,2,
                        title: "@ctitle", //模拟中文标题
                        address: "@county(true)", //模拟省市县
                        "type|0-2":0
                    },
                ],
            },
        }));
    },

    'GET /api/list': function (req, res) {
        let query = req.query || {};
        return res.json({
            limit: query.limit,
            offset: query.offset,
            list: [{
                username: 'admin1',
                sex: 1,
            }, {
                username: 'admin2',
                sex: 0,
            }]
        })
    },
    'GET /api/userinfo/:id': (req, res) => {
        return res.json({
            id: req.params.id,
            username: 'kenny',
        });
    },
    'POST /api/login/account': (req, res) => {
        const { password, username } = req.body;
        if (password === '888888' && username === 'admin') {
            return res.json({
                status: 'ok',
                token: 'sdfsdfsdfdsf',
            });
        } else {
            return res.json({
                status: 'error',
                code: 403,
            });
        }
    },
    'DELETE /api/user/:id': (req, res) => {
        // console.log(req.params.id);
        res.send({ status: 'ok', message: 'delete success!' });
    },
    'PUT /api/user/:id': (req, res) => {
        // console.log(req.params.id);
        // console.log(req.body);
        res.send({ status: 'ok', message: 'update success！' });
    },
}
